

var util=require("util");

var events = require("events");


//定义两个类

function Goddess(name){
    this.name = name;

}

function  Boy(name,say) {
    this.name = name;
    this.response=function () {
        console.log(say);

    }
}

//让女神继承事件模块

 util.inherits(Goddess,events);

//实例

var gg=new Goddess('娜美');

var boy1 = new Boy('路飞','那是当然的啦');

var boy2 = new Boy('索隆','真般配的呀');

///给女神绑定  监听者

  gg.addListener("dropRiver",boy1.response);
  gg.on("dropRiver",boy2.response);

// 只能执行一次

  gg.once("die",function () {
      console.log("ii");
  })
  // gg.removeListener('dropRiver',boy2.response);


//执行事件
gg.emit("dropRiver");
gg.emit("die");
gg.emit("die");





